package model;

import java.util.Date;

import validator.UserAccountValidator;

import model.type.SubjectType;
import db.ImbiConnection;

public class UserAccount {
	private int id;
	private int subjectType; // always 3
	private int subject;
	private String username;
	private String password;
	private int status;
	private Date validFrom;
	private Date validTo;
	private int createdBy;
	private Date created;
	private boolean passwordNeverExpires;
	
	
	
	public UserAccount(int id, int subjectType, int subject, String username,
			String password, int status, Date validFrom, Date validTo,
			int createdBy, Date created, boolean passwordNeverExpires) {		
		this.id = id;
		this.subjectType = subjectType;
		this.subject = subject;
		this.username = username;
		this.password = password;
		this.status = status;
		this.validFrom = validFrom;
		this.validTo = validTo;
		this.createdBy = createdBy;
		this.created = created;
		this.passwordNeverExpires = passwordNeverExpires;
	}

	public int getId() {
		return id;
	}
	
	public int getSubjectType() {
		return subjectType;
	}

	public void setSubjectType(int subjectType) {
		this.subjectType = subjectType;
	}

	public int getSubject() {
		return subject;
	}

	public void setSubject(int subject) {
		this.subject = subject;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Date getValidFrom() {
		return validFrom;
	}

	public void setValidFrom(Date validFrom) {
		this.validFrom = validFrom;
	}

	public Date getValidTo() {
		return validTo;
	}

	public void setValidTo(Date validTo) {
		this.validTo = validTo;
	}

	public int getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(int createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public boolean isPasswordNeverExpires() {
		return passwordNeverExpires;
	}

	public void setPasswordNeverExpires(boolean passwordNeverExpires) {
		this.passwordNeverExpires = passwordNeverExpires;
	}
	
	/*OBJECT ACCESS METHODS*/
	
	
	public Employee getEmployee(){
		return getEmployeeById(getSubject());
	}
	
	public Employee getCreaterEmployee(){
		return getEmployeeById(getCreatedBy());
	}	
	
	public SubjectType getSubjectTypeObject(){
		return SubjectType.getSubjectType(getSubjectType());
	}
	
	private Employee getEmployeeById(int id){
		return ImbiConnection.getEmployeeDAO().find(id);
	}
	

}
